package com.zmn.brs.common.enums;

import java.util.Optional;
import java.util.stream.Stream;

/**
 * 类描述：场景类型枚举
 *
 * @author chongw
 * @since 2021/05/27 10:47
 */
public enum SceneTypeEnum {

    /**
     *
     */
    SENSITIVE(1, "敏感操作"),
    TARGET(2, "绩效经营指标"),
    ORDER_TARGET(3, "订单经营指标"),
    ENGINEER_TARGET(4, "工程师指标"),
    ;

    /**
     * 类型
     */
    private final Integer typeId;

    /**
     * 类型名
     */
    private final String typeName;

    SceneTypeEnum(Integer typeId, String typeName) {

        this.typeId = typeId;
        this.typeName = typeName;
    }

    public Integer getTypeId() {

        return typeId;
    }

    public String getTypeName() {

        return typeName;
    }

    public static SceneTypeEnum getEventTypeEnum(Integer typeId) {

        Optional<SceneTypeEnum> optional = Stream.of(SceneTypeEnum.values()).filter(e -> e.getTypeId().equals(typeId)).findFirst();
        return optional.orElse(null);
    }

    public static String getTypeName(Integer typeId) {
        SceneTypeEnum of = getEventTypeEnum(typeId);
        return of == null ? null : of.getTypeName();
    }
}
